from multiprocessing import Pool


def square(x):
    return x * x


if __name__ == '__main__':
    with Pool(4) as p:  # 创建一个包含4个进程的进程池
        results = p.map(square, range(100))
        print(results)  # 输出: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
